package kg.aibek.projecteuler.p10;

import java.math.BigInteger;
import java.util.Set;
import java.util.TreeSet;

public class Problem39 {
	public void solve() {
		Set<Integer> set = new TreeSet<Integer>();
		for (int i = 1; i < 1000; i++) {
			for (int j = 1; j <= 1000 - i; j++) {
				for (int k = 1; k <= 1000 - i - j; k++) {
					if (i * i == j * j + k * k) {
						int gcd = gcd(gcd(i, j), k);
						int ni = i / gcd;
						int nj = j / gcd;
						int nk = k / gcd;

						set.add(ni + nj + nk);
					}
				}
			}
		}

		int a[] = new int[1001];
		for (int i : set) {
			for (int j = 1; i * j <= 1000; j++) {
				a[i * j]++;
			}
		}

		int max = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] >= a[max]) {
				max = i;
			}
		}
		System.out.println(max);
		System.out.println(a[max]);
	}

	private int gcd(int a, int b) {
		BigInteger aa = BigInteger.valueOf(a);
		return aa.gcd(BigInteger.valueOf(b)).intValue();
	}

	public static void main(String[] args) {
		Problem39 p = new Problem39();
		p.solve();
	}

}
